<template>
	<view class="content">
		<view class="tabs">
			<view class="tab" :class="{active:k == tabsIndex}" @click="changeTabsIndex(k)" v-for="(v,k) in tabs">
				{{v.name}}
			</view>
		</view>

		<view class="list">
			<view class="list-item" v-for="v in list">
				<view class="list-item-top">
					<view>{{v.money}}</view>
					<view>
						<view>折扣率：{{v.service_price}}</view>
						<image :src="$showImg('/images/demo/jtou.png')"></image>
					</view>
					<view class="flex align-center column">
						<view>¥人民币</view>
						<view>7.01</view>
					</view>
				</view>
				<view class="list-item-time">提现时间:2024-07-04 10:23:53</view>
			</view>
			<uEmpty v-if="!list.length"></uEmpty>
		</view>
	</view>
</template>

<script>
	import {
		getDonateList
	} from '@/API/wallet.js'
	export default {
		data() {
			return {
				tabs: [{
					name: '分佣钱包',
					field: 'commission'
				}, {
					name: '销售钱包',
					field: 'sell'
				}],
				tabsIndex: 0,

				list: [],
				page: 1,
				totalPage: 1
			}
		},
		mounted() {
			this.init()
		},
		onPullDownRefresh() {
			this.init()
		},
		onReachBottom() {
			this.getList()
		},
		methods: {
			init() {
				this.page = 1
				this.getList()
			},
			changeTabsIndex(k) {
				this.tabsIndex = k
				this.init()
			},
			getList() {
				if (this.page > this.totalPage) return
				getDonateList({
					page: this.page,
					wallet_type: this.tabs[this.tabsIndex].field
				}).then(res => {
					console.log('-=-=-=res', res)
					let list = res.data.data
					if (this.page > 1) {
						list = this.list.concat(res.data.data)
					}
					this.list = list
					this.page++
					this.totalPage = res.data.last_page || 1
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 0 20rpx 20rpx;

		.tabs {
			display: flex;
			justify-content: space-around;
			align-items: center;
			height: 100rpx;
			position: fixed;
			top: 0rpx;
			left: 0;
			width: 750rpx;
			background-color: #F6F6F6;
			padding-bottom: 20rpx;
			z-index: 10;

			.tab {
				position: relative;
			}

			.tab.active::before {
				content: '';
				position: absolute;
				width: 30rpx;
				height: 6rpx;
				background: linear-gradient(90deg, #DD551B, #F49355);
				border-radius: 3rpx;
				bottom: -20rpx;
				left: 0;
				right: 0;
				margin: auto
			}
		}

		.list {
			margin-top: 120rpx;
			display: flex;
			flex-direction: column;
			gap: 20rpx;

			&-item {
				background-color: #fff;
				padding: 30rpx 25rpx;
				border-radius: 16rpx;
				display: flex;
				flex-direction: column;
				gap: 30rpx;

				&-top {
					display: flex;
					align-items: center;
					justify-content: space-between;
				}

				&-top>view:nth-child(1) {
					font-weight: bold;
					font-size: 30rpx;
					color: #EB5C20;
					line-height: 34rpx;
				}

				&-top>view:nth-child(2) {
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
					line-height: 34rpx;
					display: flex;
					flex-direction: column;
					justify-content: center;
					gap: 10rpx;
					align-items: center;

					image {
						width: 242rpx;
						height: 8rpx;
					}
				}

				&-top>view:nth-child(3) {
					display: flex;
					flex-direction: column;
					justify-content: center;
					gap: 17rpx;
					align-items: center;

					>view:nth-child(1) {
						padding: 9rpx;
						background: linear-gradient(90deg, #DD551B, #F49355);
						border-radius: 5rpx;
						font-weight: 400;
						font-size: 20rpx;
						color: #FDFDFD;
					}

					>view:nth-child(2) {
						font-weight: bold;
						font-size: 30rpx;
						color: #D50101;
						line-height: 34rpx;
					}
				}

				&-time {
					font-weight: 400;
					font-size: 26rpx;
					color: #888888;
				}
			}
		}
	}
</style>